package internal

import (
	"gameserver/gcommon"
	"sync"

	"gitee.com/night-tc/gobige/dblink"
	"gitee.com/night-tc/gobige/etcd"
	"gitee.com/night-tc/gobige/global"
	"gitee.com/night-tc/gobige/logger"
	"gitee.com/night-tc/gobige/serverMgr"
	"gitee.com/night-tc/gobige/timerwheel"
)

/*
数据库里的表数据
*/

var (
	one     sync.Once
	srvinst IService
)

type IService interface {
	global.IsrvInst
	timerwheel.ITimer

	// 获取ETCD的实例
	GetEtcd() *etcd.EtcdAccess
	// 获取服务器负载器
	GetDirMgr() *serverMgr.DiscoveryMgr
	// 获取mysql管理器
	GetMysqlMgr() *dblink.MysqlAccess
	// 获取本服务器实例配置
	GetSInfo() *gcommon.ServiceConfig
	// 获取Linker服务实例
	GetLinkerSrv(groupid uint32) *LinkerSrv
}

func GetSrvinst() IService {
	one.Do(func() {
		ok := false
		srvinst, ok = global.GetSrvInst().(IService)
		if !ok {
			logger.Fatal("Login.GetSrvinst.")
		}
	})
	return srvinst
}
